/**
 * 管理员个人资料中的修改功能 的信息修改
 */
package controller;

import hibernate.Adminstab;
import hibernate.AdminstabDAO;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;

public class AdminInfoUpdateSuccess implements Action{
	private String name;
	private String mobile;
	private String mail;
	

	public String getName() {
		return name;
	}


	public void setName(String name) {
		this.name = name;
	}


	public String getMobile() {
		return mobile;
	}


	public void setMobile(String mobile) {
		this.mobile = mobile;
	}


	public String getMail() {
		return mail;
	}


	public void setMail(String mail) {
		this.mail = mail;
	}


	public String execute() throws Exception {
		AdminstabDAO adminstabDAO=new AdminstabDAO();
		adminstabDAO.getSession().beginTransaction();
		ActionContext ctx = ActionContext.getContext();
		try
		{
			Adminstab adminstab = (Adminstab)adminstabDAO.findByAccount(ctx.getSession().get("account")).get(0);
			adminstab.setName(name);
			adminstab.setMail(mail);
			adminstab.setTelNumber(mobile);

			adminstabDAO.getSession().update(adminstab);
			adminstabDAO.getSession().getTransaction().commit();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		finally
		{
			adminstabDAO.getSession().close();
		}
		return SUCCESS;
	}

}
